package com.zkt.practice.server.rpc;

import com.zkt.auth.api.UserFeignService;
import com.zkt.auth.entity.AuthUserDTO;
import com.zkt.auth.common.entity.Result;
import com.zkt.practice.server.entity.dto.UserInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * @author zkt
 */

@Component
public class UserRpc {
	
	@Resource
	private UserFeignService userFeignService;
	
	public UserInfo getUserInfo(String userName) {
		Result<AuthUserDTO> result = userFeignService.getUserInfo(userName);
		UserInfo userInfo = new UserInfo();
		if (!result.getSuccess()) {
			return userInfo;
		}
		AuthUserDTO data = result.getData();
		userInfo.setUserName(data.getUserName());
		userInfo.setNickName(data.getNickname());
		userInfo.setAvatar(data.getAvatar());
		return userInfo;
	}
	
}
